package no.hio.wsprovider.dao;

import java.util.ArrayList;
import java.util.List;

import junit.framework.TestCase;

import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
import no.hio.wsprovider.dao.*;
import no.hio.wsprovider.vo.Product;

public class UtilTestCase extends TestCase {

	@Before
	public void setUp() throws Exception {
	}
	
	
	@Test
	public void testGetNextIdentifier()
	{
		List<Product> list = new ArrayList<Product>();
		
		Product p1, p2, p3;
		p1 = new Product();
		p2 = new Product();
		
		p1.setProductID(1);
		p2.setProductID(7);
		
		
		list.add(p1);
		list.add(p2);
		
		assertEquals("Forventet verdi er 3", 8, Util.getNextIdentifier(list));
		
		p3 = new Product();
		p3.setProductID(10);
		list.add(p3);
		
		assertEquals("Forventet var 11",11, Util.getNextIdentifier(list));
		
	}
	
	@Test
	public void testEmptyList()
	{
		List<Product> list = new ArrayList<Product>();
		
		assertEquals("Forventet verdi er 1",1, Util.getNextIdentifier(list));
	}

}
